<template>
  <div id="solidcapsule"></div>
</template>

<script lang="ts" setup>
import { onMounted } from 'vue'
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'

const scene = new THREE.Scene()
const geometry = new THREE.CapsuleGeometry(5, 10, 10, 15)
const humbleMaterial = new THREE.MeshBasicMaterial({
    color: 'wihte',
    wireframe: true,
})

const humbleMesh = new THREE.Mesh(geometry, humbleMaterial)

scene.add(humbleMesh)

const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.set(0, 0, 50)

const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)

const animate = () => {
    requestAnimationFrame(animate)
    humbleMesh.rotation.x += 0.01
    humbleMesh.rotation.y += 0.01
    humbleMesh.rotation.z += 0.01
    renderer.render(scene, camera)
}

window.onresize = () => {
    renderer.setSize(window.innerWidth, window.innerHeight)
    camera.aspect = window.innerWidth / window.innerHeight
    camera.updateProjectionMatrix()
}

onMounted(() => {
    new OrbitControls(camera, renderer.domElement)
    document.getElementById('solidcapsule').appendChild(renderer.domElement)
    animate()
})

</script>

<style>

</style>